package com.py.credit.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.py.credit.common.Page;
import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.Companymess;
import com.py.credit.entity.DeptNum;
import com.py.credit.entity.Feedback;
import com.py.credit.entity.IntegratedQuery;
import com.py.credit.entity.Measure;
import com.py.credit.entity.Person;
import com.py.credit.entity.SysUser;
import com.py.credit.entity.common.OptionalColumn;
import com.py.credit.entity.enums.CjFrTableFieldEnum;
import com.py.credit.entity.enums.CjZrrTableFieldEnum;
import com.py.credit.entity.enums.JlFrTableFieldEnum;
import com.py.credit.entity.enums.JlZrrTableFieldEnum;
import com.py.credit.service.IntegratedQueryService;
import com.py.credit.service.LhjcRemoteBaseService;
import com.py.credit.service.OfficeService;
import com.py.credit.service.RemovalService;
import com.py.credit.service.SyslogService;
import com.py.credit.utils.ExcelUtil;
import com.py.credit.utils.MapCache;
import com.py.framework.core.helper.HttpServletHelper;

@Controller
@RequestMapping("/integratedQuery")
public class IntegratedQueryController {

    private final static String FRONT_TABLE_CJFR_ID = "cjfr";

    private final static String FRONT_TABLE_CJZRR_ID = "cjzrr";

    private final static String FRONT_TABLE_JLFR_ID = "jlfr";

    private final static String FRONT_TABLE_JLZRR_ID = "jlzrr";

    @Autowired
    private IntegratedQueryService integratedQueryService;

    @Autowired
    private LhjcRemoteBaseService lhjcRemoteBaseService;

    @Autowired
    private OfficeService officeService;

    @Autowired
    private SyslogService syslogService;

    @Autowired
    private RemovalService removalService;

    /**
     * 联合奖惩事件普通检索
     *
     * @param jclb 奖惩类别：C:惩戒 J:激励
     * @param type 主体类型：C：法人 P:自然人
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getOptionalColums.json")
    public RestServiceResult getOptionalColums(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                                               @RequestParam(value = "type", defaultValue = "", required = true) String type) {
        if (jclb.equals("C") && type.equals("C")) {
            return new RestServiceResult(CjFrTableFieldEnum.getOptionalColumns());
        } else if (jclb.equals("C") && type.equals("P")) {
            return new RestServiceResult(CjZrrTableFieldEnum.getOptionalColumns());
        } else if (jclb.equals("J") && type.equals("C")) {
            return new RestServiceResult(JlFrTableFieldEnum.getOptionalColumns());
        } else {
            return new RestServiceResult(JlZrrTableFieldEnum.getOptionalColumns());
        }
    }

    /**
     * 联合奖惩事件高级检索
     *
     * @param jclb 奖惩类别：C:惩戒 J:激励
     * @param type 主体类型：C：法人 P:自然人
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getAdvancedConditionColumns.json")
    public RestServiceResult getAdvancedConditionColumns(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                                                         @RequestParam(value = "type", defaultValue = "", required = true) String type) {
        if (jclb.equals("C") && type.equals("C")) {
            return new RestServiceResult(CjFrTableFieldEnum.getAdvancedConditionColumns());
        } else if (jclb.equals("C") && type.equals("P")) {
            return new RestServiceResult(CjZrrTableFieldEnum.getAdvancedConditionColumns());
        } else if (jclb.equals("J") && type.equals("C")) {
            return new RestServiceResult(JlFrTableFieldEnum.getAdvancedConditionColumns());
        } else {
            return new RestServiceResult(JlZrrTableFieldEnum.getAdvancedConditionColumns());
        }
    }

    /**
     * 联合奖惩综合查询分页列表
     *
     * @param jclb      奖惩类别：C:惩戒 J:激励
     * @param type      主体类型：C：法人 P:自然人
     * @param condition 搜索条件
     * @param page      分页条件
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/list.json")
    public RestServiceResult getList(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                                     @RequestParam(value = "type", defaultValue = "", required = true) String type,
                                     @RequestParam(value = "lingyu", defaultValue = "", required = false) String lingyu,
                                     @RequestParam(value = "status", defaultValue = "", required = false) String status,
                                     @RequestParam(value = "condition", defaultValue = "", required = true) String condition,
                                     Page page, HttpServletRequest request) {
        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        String[] configColumns = null;
        List<String> showColumns = null;

        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            SysUser userInfo = user.getData();
            if (null != userInfo) {
                if (jclb.equals("C") && type.equals("C")) {
                    configColumns = (String[]) MapCache.get(userInfo.getId() + "_" + FRONT_TABLE_CJFR_ID);
                    showColumns = (configColumns == null || configColumns.length == 0)
                            ? CjFrTableFieldEnum.getDefaultShowColumnEN() : Arrays.asList(configColumns);
                } else if (jclb.equals("C") && type.equals("P")) {
                    configColumns = (String[]) MapCache.get(userInfo.getId() + "_" + FRONT_TABLE_CJZRR_ID);
                    showColumns = (configColumns == null || configColumns.length == 0)
                            ? CjZrrTableFieldEnum.getDefaultShowColumnEN() : Arrays.asList(configColumns);
                } else if (jclb.equals("J") && type.equals("C")) {
                    configColumns = (String[]) MapCache.get(userInfo.getId() + "_" + FRONT_TABLE_JLFR_ID);
                    showColumns = (configColumns == null || configColumns.length == 0)
                            ? JlFrTableFieldEnum.getDefaultShowColumnEN() : Arrays.asList(configColumns);
                } else {
                    configColumns = (String[]) MapCache.get(userInfo.getId() + "_" + FRONT_TABLE_JLZRR_ID);
                    showColumns = (configColumns == null || configColumns.length == 0)
                            ? JlZrrTableFieldEnum.getDefaultShowColumnEN() : Arrays.asList(configColumns);
                }
            } else {
                ExceptionLogger.error("IntegratedQueryController#getList", "未获取到当前用户信息！");
            }
        } else {
            ExceptionLogger.error("IntegratedQueryController#getList", "未获取到当前用户信息！");
        }

        String[] additionalColumns = {"id", "gzId"};

        List<Map<String, Object>> integratedQuery = integratedQueryService.selectByConditionForPage(status,lingyu,jclb, type, showColumns, additionalColumns, condition, page);

        for (int i = 0; i < integratedQuery.size(); i++) {
        	
            List<Integer> list = integratedQueryService.selectDeptId((Integer) integratedQuery.get(i).get("gzId"));
            int ygNum = 0;
            if (list.contains(-1)) {
                ygNum = integratedQueryService.selectAllDept();
            } else {
                ygNum = list.size();
            }
            
            int sjNum = integratedQueryService.selectFkDept((String) integratedQuery.get(i).get("ajbh"));
            String num = sjNum + "/" + ygNum;
//            String num = new BigDecimal(sjNum).multiply(new BigDecimal(100)).divide(new BigDecimal(ygNum),2,RoundingMode.HALF_UP) + "%";
            integratedQuery.get(i).put("fkzb", num);
        }

        return new RestServiceResult(page.getTotalCount(), integratedQuery);
    }

    /**
     * 获取数据
     *
     * @param ajbh 事件编号
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectOneByAjbh.json")
    public RestServiceResult selectOneByAjbh(@RequestParam(defaultValue = "", required = true, value = "ajbh") String ajbh) {
        IntegratedQuery integratedQuery = integratedQueryService.selectByAjbh(ajbh);
        int gzId = integratedQuery.getGzId();

        String cybm = "";
        if (integratedQueryService.selectCyDeptIsAllDept(gzId) < 1) {
            cybm = integratedQueryService.selectCyDeptName(gzId);
        } else {
            cybm = "所有部门";
        }

        String tybm = integratedQuery.getTybm();
        String type = integratedQuery.getType();
        Companymess companymess = integratedQueryService.selectByTybm(tybm, type);

        Map<String, Object> map = new HashMap<String, Object>();
        List<String> list = new ArrayList<String>();
        List<Person> list1 = new ArrayList<Person>();
        if (integratedQuery.getType().equals("C")) {
            if (integratedQuery.getIs_associated().equals("Y")) {
                String[] zrrAjbh = integratedQuery.getGlcf().split(",");
                for (int i = 0; i < zrrAjbh.length; i++) {
                    IntegratedQuery integratedQuery1 = integratedQueryService.selectByAjbh(zrrAjbh[i]);
                    list.add(integratedQuery1.getBm());
                }
                for (int i = 0; i < list.size(); i++) {
                    Person person = integratedQueryService.selectZrrInfo(list.get(i));
                    list1.add(person);
                }
            }
        } else {
            if (integratedQuery.getIs_associated().equals("Y")) {
                integratedQuery.setQymc(removalService.selectInfo(integratedQuery.getGlcf()).getZtmc());
            }

            integratedQuery.setGlcf("<a href='javascript:void(0)' onclick='detail(\"" + integratedQuery.getGlcf() + "\");'>" + integratedQuery.getGlcf() + "</a>");
        }

        map.put("integratedQuery", integratedQuery);
        map.put("companymess", companymess);
        map.put("person", list1);
        map.put("cybm", cybm);
        map.put("lhjcProcess", syslogService.getProcessList(ajbh));
        return new RestServiceResult(map);
    }

    /**
     * 反馈详情列表
     *
     * @param ajbh      事件编号
     * @param managerId 用户id
     * @param page      分页条件
     * @return
     */
    @ResponseBody
    @RequestMapping("/feedBackList.json")
    public RestServiceResult feedBackListForPage(@RequestParam(defaultValue = "", required = true, value = "ajbh") String ajbh,
                                                 @RequestParam(defaultValue = "", required = true, value = "managerId") String managerId, Page page) {
        List<Feedback> feedbacks = integratedQueryService.feedBackListForPage(ajbh, managerId, page);
        return new RestServiceResult(page.getTotalCount(), feedbacks);
    }


    /**
     * 部门反馈数量
     *
     * @param ajbh 事件编号
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectNumForDept.json")
    public RestServiceResult feedbackDetail(@RequestParam(defaultValue = "", required = true, value = "ajbh") String ajbh) {
        List<DeptNum> deptNums = integratedQueryService.selectNumForDept(ajbh);

        Map<String, Object> map = new HashMap<String, Object>();

        if (integratedQueryService.selectExistAllDeptByAjbh(ajbh) > 0) {
            DeptNum allDept = new DeptNum();
            allDept.setData("所有部门");
            allDept.setNum(integratedQueryService.selectNumForAllDept(ajbh));
            deptNums.add(allDept);
        }

        map.put("deptNums", deptNums);
        return new RestServiceResult(map);
    }

    /**
     * 获取反馈数据
     *
     * @param ajbh    事件编号
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectFkOneByAjbh.json")
    public RestServiceResult selectFkOneByAjbh(@RequestParam(defaultValue = "", required = true, value = "ajbh") String ajbh, HttpServletRequest request) {
        // 获取当前用户信息
        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                ExceptionLogger.error("IntegratedQueryController#selectFkOneByAjbh", "未获取到当前用户信息！");
                return new RestServiceResult(RestServiceResult.CODE_UNKNOW, "系统异常，请稍后再试！");
            }

            String deptId = officeService.selectTopDeptId(userInfo.getOfficeId() + "");
            IntegratedQuery integratedQuery = integratedQueryService.selectByAjbh(ajbh);
            int gzId = integratedQuery.getGzId();
            String tybm = integratedQuery.getTybm();
            String type = integratedQuery.getType();
            List<Measure> measures = new ArrayList<Measure>();
            Companymess companymess = integratedQueryService.selectByTybm(tybm, type);
            
            if(null == companymess) {
            	throw new IllegalStateException("暂未查到数据，请稍后再试。");
            }

            if (integratedQuery.getType().equals("P")) {
                measures = integratedQueryService.selectFkCsByAjbh("P", gzId, deptId);
            } else {
                measures = integratedQueryService.selectFkCsByAjbh("C", gzId, deptId);
            }

            Map<String, Object> map = new HashMap<String, Object>();
            List<String> list = new ArrayList<String>();
            List<Person> list1 = new ArrayList<Person>();
            if (integratedQuery.getType().equals("C")) {
                if (integratedQuery.getIs_associated().equals("Y")) {
                    String[] zrrAjbh = integratedQuery.getGlcf().split(",");
                    for (int i = 0; i < zrrAjbh.length; i++) {
                        IntegratedQuery integratedQuery1 = integratedQueryService.selectByAjbh(zrrAjbh[i]);
                        list.add(integratedQuery1.getBm());
                    }
                    for (int i = 0; i < list.size(); i++) {
                        Person person = integratedQueryService.selectZrrInfo(list.get(i));
                        list1.add(person);
                    }
                }
            } else {
                integratedQuery.setGlcf("<a href='javascript:void(0)' onclick='detail(\"" + integratedQuery.getGlcf() + "\");'>" + integratedQuery.getGlcf() + "</a>");
            }

            map.put("integratedQuery", integratedQuery);
            map.put("companymess", companymess);
            map.put("measures", measures);
            map.put("person", list1);
            return new RestServiceResult(map);
        } else {
            return new RestServiceResult(user.getCode(), user.getMsg());
        }
    }

    /**
     * Excel统计导出
     *
     * @param jclb     奖惩类别：C:惩戒 J:激励
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/exportExcel.xls")
    public RestServiceResult ExcelExport(@RequestParam(defaultValue = "", required = true, value = "jclb") String jclb, HttpServletRequest request, HttpServletResponse response) {
        // 获取当前用户信息
        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                ExceptionLogger.error("IntegratedQueryController#exportExcel", "未获取到当前用户信息！");
                return new RestServiceResult(RestServiceResult.CODE_UNKNOW, "系统异常，请稍后再试！");
            }

            String deptId = officeService.selectTopDeptId(userInfo.getOfficeId() + "");
            integratedQueryService.excelExport(response, deptId, jclb);
            return null;
        } else {
            return new RestServiceResult(user.getCode(), user.getMsg());
        }
    }

    /**
     * 图表数据
     *
     * @param jclb      奖惩类别：C:惩戒 J:激励
     * @param ztmc      主体名称
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param page      分页条件
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/chartsDetailList.json")
    public RestServiceResult getChartsDetailList(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                                                 @RequestParam(value = "ztmc", defaultValue = "", required = true) String ztmc,
                                                 @RequestParam(value = "startTime", defaultValue = "", required = true) String startTime,
                                                 @RequestParam(value = "endTime", defaultValue = "", required = true) String endTime, Page page, HttpServletRequest request) {
        // 获取当前用户信息
        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                ExceptionLogger.error("IntegratedQueryController#selectFkOneByAjbh", "未获取到当前用户信息！");
                return new RestServiceResult(RestServiceResult.CODE_UNKNOW, "系统异常，请稍后再试！");
            }

            String deptId = officeService.selectTopDeptId(userInfo.getOfficeId() + "");
            List<IntegratedQuery> integratedQuery = integratedQueryService.getChartsDetailListForPage(jclb, ztmc, startTime, endTime, page);
            for (int i = 0; i < integratedQuery.size(); i++) {
                List<Integer> list = integratedQueryService.selectDeptId(integratedQuery.get(i).getGzId());
                int ygNum = 0;
                if (list.contains(-1)) {
                    ygNum = integratedQueryService.selectAllDept();
                } else {
                    ygNum = list.size();
                }

                int sjNum = integratedQueryService.selectFkDept(integratedQuery.get(i).getAjbh());
                String num = sjNum + "/" + ygNum;
                integratedQuery.get(i).setFkzb(num);

                integratedQuery.get(i).setAjbh("<a href='javascript:void(0)' onclick='detail(\"" + integratedQuery.get(i).getAjbh() + "\");'>" + integratedQuery.get(i).getAjbh() + "</a>");
            }

            return new RestServiceResult(page.getTotalCount(), integratedQuery);
        } else {
            return new RestServiceResult(user.getCode(), user.getMsg());
        }
    }

    /**
     * 通报部门查看详情
     *
     * @param ajbh    事件编号
     * @param page    分页条件
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/measureList.json")
    public RestServiceResult getMeasureListForPage(@RequestParam(defaultValue = "", required = true, value = "ajbh") String ajbh, Page page, HttpServletRequest request) {
        // 获取当前用户信息
        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                ExceptionLogger.error("IntegratedQueryController#getMeasureListForPage", "未获取到当前用户信息！");
                return new RestServiceResult(RestServiceResult.CODE_UNKNOW, "系统异常，请稍后再试！");
            }
        } else {
            return new RestServiceResult(user.getCode(), user.getMsg());
        }

        IntegratedQuery integratedQuery = integratedQueryService.selectByAjbh(ajbh);
        int gzId = integratedQuery.getGzId();
        List<Measure> measures = new ArrayList<Measure>();

        if (integratedQuery.getType().equals("P")) {
            measures = integratedQueryService.selectCsByAjbhForPage("P", gzId, page);
        } else {
            measures = integratedQueryService.selectCsByAjbhForPage("C", gzId, page);
        }

        return new RestServiceResult(page.getTotalCount(), measures);
    }

    /**
     * 自定义列表选项
     *
     * @param jclb    奖惩类别：C:惩戒，J:激励
     * @param type    主体类型：C：法人 P:自然人
     * @param columns 列表数组
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/addShowColunms.json")
    public RestServiceResult<String> addShowColunms(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                                                    @RequestParam(value = "type", defaultValue = "", required = true) String type,
                                                    @RequestParam(value = "columns", required = true) String[] columns,
                                                    HttpServletRequest request) {

        RestServiceResult<SysUser> user = lhjcRemoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));

        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {

            SysUser userInfo = user.getData();

            if (null != userInfo) {

                if (jclb.equals("C") && type.equals("C")) {
                    MapCache.set(userInfo.getId() + "_" + FRONT_TABLE_CJFR_ID, columns);
                } else if (jclb.equals("C") && type.equals("P")) {
                    MapCache.set(userInfo.getId() + "_" + FRONT_TABLE_CJZRR_ID, columns);
                } else if (jclb.equals("J") && type.equals("C")) {
                    MapCache.set(userInfo.getId() + "_" + FRONT_TABLE_JLFR_ID, columns);
                } else {
                    MapCache.set(userInfo.getId() + "_" + FRONT_TABLE_JLZRR_ID, columns);
                }

            } else {

                ExceptionLogger.error("IntegratedQueryController#addShowColunms", "未获取到当前用户信息！");
            }

        } else {

            ExceptionLogger.error("IntegratedQueryController#addShowColunms", "未获取到当前用户信息！");
        }

        return new RestServiceResult<String>();
    }

    /**
     * 高级检索文件导出
     *
     * @param jclb      奖惩类别：C:惩戒，J:激励
     * @param type      主体类型：C：法人 P:自然人
     * @param condition 查询条件
     * @param columnEN  字段名
     * @param page      分页条件
     * @param response
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value = "/export.json")
    public void export(@RequestParam(value = "jclb", defaultValue = "", required = true) String jclb,
                       @RequestParam(value = "type", defaultValue = "", required = true) String type,
                       @RequestParam(value = "lingyu", defaultValue = "", required = false) String lingyu,
                       @RequestParam(value = "status", defaultValue = "", required = false) String status,
                       @RequestParam(value = "condition", defaultValue = "", required = true) String condition,
                       @RequestParam(value = "columnEN", defaultValue = "", required = true) String columnEN, Page page,
                       HttpServletResponse response) throws IOException {

        page.setLimit(1000);

        List<String> columns = JSONArray.parseArray(columnEN, String.class);
        
        String[] additionalColumns = {"id", "gzId"};

        List<Map<String, Object>> data = integratedQueryService.selectByConditionForPage(status,lingyu,jclb, type, columns,
        		additionalColumns, condition, page);
        
        for (int i = 0; i < data.size(); i++) {
        	
            List<Integer> list = integratedQueryService.selectDeptId((Integer) data.get(i).get("gzId"));
            int ygNum = 0;
            if (list.contains(-1)) {
                ygNum = integratedQueryService.selectAllDept();
            } else {
                ygNum = list.size();
            }

            int sjNum = integratedQueryService.selectFkDept((String) data.get(i).get("ajbh"));
            String num = sjNum + "/" + ygNum;
//            String num = new BigDecimal(sjNum).multiply(new BigDecimal(100)).divide(new BigDecimal(ygNum),2,RoundingMode.HALF_UP) + "%";
            data.get(i).put("fkzb", num);
        }
        
        

        List<OptionalColumn> optionalColumns = null;

        String excelName = "";
        if (jclb.equals("C") && type.equals("C")) {
            optionalColumns = CjFrTableFieldEnum.getOptionalColumns();
            excelName = "法人联合惩戒事件";
        } else if (jclb.equals("C") && type.equals("P")) {
            optionalColumns = CjZrrTableFieldEnum.getOptionalColumns();
            excelName = "自然人联合惩戒事件";
        } else if (jclb.equals("J") && type.equals("C")) {
            optionalColumns = JlFrTableFieldEnum.getOptionalColumns();
            excelName = "法人联合激励事件";
        } else {
            optionalColumns = JlZrrTableFieldEnum.getOptionalColumns();
            excelName = "自然人联合激励事件";
        }

        ExcelUtil.downloadExcel(response, data, excelName, excelName, columns, optionalColumns);
    }

    /**
     * 查询反馈占比列表
     * @param ajbh 事件编号
     * @param page 分页条件
     * @return
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value = "/selectFkzbList.json")
    public RestServiceResult selectFkzbList(@RequestParam(value = "ajbh", defaultValue = "", required = true) String ajbh,
                       Page page) throws IOException {
        @SuppressWarnings("rawtypes")
		List<LinkedHashMap> data = integratedQueryService.selectFkzbListForPage(ajbh,page);
        return new RestServiceResult(page.getTotalCount(), data);
    }

    /**
     * Excel反馈占比列表统计导出
     * @param ajbh 事件编号
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/exportFkzbExcel.json")
    public void exportFkzbExcel(@RequestParam(value = "ajbh", defaultValue = "", required = true) String ajbh,
                                         HttpServletResponse response) {
        integratedQueryService.exportFkzbExcel(response,ajbh);
    }
    
    @ResponseBody
    @RequestMapping(value = "/guiji.json")
    public RestServiceResult<List<Map>> getXyjgGuiji(@RequestParam(defaultValue = "", required = true, value = "ztmc") String ztmc,
    		@RequestParam(defaultValue = "", required = true, value = "bm") String bm,
    		@RequestParam(defaultValue = "", required = true, value = "type") String type,
    		HttpServletRequest request) {
    	
    	List<Map> lhcjList = integratedQueryService.getLhcj(ztmc,bm,type);
    	
    	return new RestServiceResult<>(lhcjList);
    }
    
}
